package com.msb.userclient.controller;

import com.alibaba.fastjson2.JSONObject;
import com.msb.userclient.client.UserClient;
import com.msb.userclient.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author DreamAndLove
 * @date 2024/09/05 16:32
 * @description
 */
@RestController
public class UserController {

    @Autowired
    UserClient userClient;

    @Autowired
    UserService userService;

    @Value("${server.port}")
    String port;


    @GetMapping("/userconsumer/user")
    public JSONObject getUser() {
        JSONObject user = userClient.getUser();
        user.put("consumer port", port);
        return user;
    }

    @GetMapping("/userapi/user")
    public JSONObject getApiUser() {
        JSONObject user = userClient.getUserInfo("lisi");
        user.put("consumer port", port);
        return user;
    }

    @GetMapping("/timeout")
    public String timeoutTest(){
        String string = userClient.timeoutTest();
        return string;
    }

    @GetMapping("/timeout1")
    public String timeoutTest1(){
        String string = userService.timeoutTest();
        return string;
    }
}
